def Kadane(arr):
    max_so_far = float('-inf')  # 负无穷大
    current_sum = 0
    for x in arr:
        current_sum += x
        max_so_far = max(max_so_far,current_sum)
        if current_sum < 0:
            current_sum = 0
    return max_so_far


import sys
# 提高递归深度限制和栈大小限制（如果有需要）
sys.setrecursionlimit(10000)
# 修改标准输入输出以提高效率
input = sys.stdin.read
data = input().split()

n = int(data[0])
a = [list(map(int, data[1 + i * n:1 + (i + 1) * n])) for i in range(n)]
max_sum = float('-inf')
for i in range(n): # 读取行
    temp = [0] * n
    for j in range(i,n): # 压缩矩阵，列相加
        for k in range(n):
            temp[k] += a[j][k]
        current_max = Kadane(temp)
        max_sum = max(max_sum,current_max)

print(max_sum)



